<div class="form">
<?php 
Yii::app()->clientScript->registerScript('sameAsPostal', "
$('#sameAsPostal').click(function(){
	if($(this).is(':checked')){
		$('#Customer_physicalAddress').val($('#Customer_postalAddress').val());
		$('#Customer_physicalSuburb').val($('#Customer_postalSuburb').val());
		$('#Customer_physicalPostcode').val($('#Customer_postalPostcode').val());
		$('#Customer_physicalState').val($('#Customer_postalState').val());
		$('#Customer_physicalCountry').val($('#Customer_postalCountry').val());
	}else{
		$('#Customer_physicalAddress').val('');
		$('#Customer_physicalSuburb').val('');
		$('#Customer_physicalPostcode').val('');
		$('#Customer_physicalState').val('');
		$('#Customer_physicalCountry').val('');
	}
});
");
?>


<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'customer-form',
	'enableAjaxValidation'=>true,
	'clientOptions' => array('validateOnSubmit' => true,
   							 'validateOnChange' => false)
)); ?>

<p class="note">Fields with <span class="required">*</span> are required.</p>

<?php echo $form->errorSummary($model); ?>
<?php if(!empty($copyFromCustomer)): ?>
<fieldset>
<legend>From Customer</legend>
<div>
This customer is <?php 
echo CHtml::link($copyFromCustomer->getFullName(),array('view','id'=>$copyFromCustomer->id));?>'s
<?php echo CHtml::textField('createRelation')?>.
</div>
</fieldset>
<?php endif; ?>

<fieldset>
<legend>Internal Use</legend>
	<div class="span-4">
		<?php echo $form->labelEx($model,'consultant'); ?>
		<?php echo $form->textField($model,'consultant',array('size'=>15,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'consultant'); ?>
	</div>
	<div class="span-4">
		<?php echo $form->labelEx($model,'valueStar'); ?>
		<?php echo $form->dropDownList($model,'valueStar',DataUtil::getNumers(5)); ?>
		<?php echo $form->error($model,'valueStar'); ?>
	</div>
	<div class="clear"></div>
</fieldset>

<fieldset>
<legend>Personal Information</legend>
	
	<div class="span-3">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php echo $form->dropDownList($model,'title',DataUtil::getTitles(),array('empty'=>'')); ?>
		<?php echo $form->error($model,'title'); ?>
	</div>

	<div class="span-3">
		<?php echo $form->labelEx($model,'firstName'); ?>
		<?php echo $form->textField($model,'firstName',array('size'=>10,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'firstName'); ?>
	</div>

	<div class="span-3">
		<?php echo $form->labelEx($model,'lastName'); ?>
		<?php echo $form->textField($model,'lastName',array('size'=>10,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'lastName'); ?>
	</div>
	
	<div class="span-3">
		<?php echo $form->labelEx($model,'otherName'); ?>
		<?php echo $form->textField($model,'otherName',array('size'=>10,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'otherName'); ?>
	</div>

	<div class="span-2">
		<?php echo $form->labelEx($model,'gender'); ?>
		<?php echo $form->dropDownList($model,'gender',DataUtil::getGenders(),array('empty'=>'')); ?>
		<?php echo $form->error($model,'gender'); ?>
	</div>

	<div class="span-3 last">
		<?php echo $form->labelEx($model,'dateOfBirth'); ?>
		<?php 
		$this->widget('zii.widgets.jui.CJuiDatePicker', array(
		    'model'=>$model,
			'attribute'=>"dateOfBirth",
			'htmlOptions'=>array('size'=>12),
		    'options'=>array(
				//'altField'=>'#'.CHtml::activeId($model, "dateOfBirth"),	
				'yearRange'=>'c-100:c',		
		    ),	
		    //'value'=>$model->dateOfBirth?$model->dateOfBirth:null,	   
		));
		?>
		<?php echo $form->error($model,'dateOfBirth'); ?>
	</div>
	<div class="clear"></div>
	<div class="span-4">
		<?php echo $form->labelEx($model,'contactPhone'); ?>
		<?php echo $form->textField($model,'contactPhone',array('size'=>15,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'contactPhone'); ?>
	</div>
	<div class="span-4">
		<?php echo $form->labelEx($model,'contactMobile'); ?>
		<?php echo $form->textField($model,'contactMobile',array('size'=>15,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'contactMobile'); ?>
	</div>
	<div class="span-4">
		<?php echo $form->labelEx($model,'contactFax'); ?>
		<?php echo $form->textField($model,'contactFax',array('size'=>15,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'contactFax'); ?>
	</div>

	<div class="span-4 last">
		<?php echo $form->labelEx($model,'email'); ?>
		<?php echo $form->textField($model,'email',array('size'=>30,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'email'); ?>
	</div>
	
	<div class="clear"></div>
</fieldset>

<fieldset>
<legend>Company</legend>
	<div class="span-4">
		<?php echo $form->labelEx($model,'companyName'); ?>
		<?php echo $form->textField($model,'companyName',array('size'=>15,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'companyName'); ?>
	</div>
	<div class="clear"></div>
</fieldset>

<fieldset>
<legend>Address Information</legend> 
	<div class="hint">When editing customer, postal address change will be logged.</div>
	<div class="row">
		<?php echo $form->labelEx($model,'postalAddress'); ?>
		<?php echo $form->textField($model,'postalAddress',array('size'=>40,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'postalAddress'); ?>
	</div>
	<div class="clear"></div>
	<div class="span-4">
		<?php echo $form->labelEx($model,'postalSuburb'); ?>
		<?php echo $form->textField($model,'postalSuburb',array('size'=>15,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'postalSuburb'); ?>
	</div>

	<div class="span-4">
		<?php echo $form->labelEx($model,'postalPostcode'); ?>
		<?php echo $form->textField($model,'postalPostcode',array('size'=>10,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'postalPostcode'); ?>
	</div>

	<div class="span-4">
		<?php echo $form->labelEx($model,'postalState'); ?>
		<?php echo $form->dropDownList($model,'postalState',DataUtil::getStates(),array('empty'=>'')); ?>
		<?php echo $form->error($model,'postalState'); ?>
	</div>

	<div class="span-4 last">
		<?php echo $form->labelEx($model,'postalCountry'); ?>
		<?php echo $form->textField($model,'postalCountry',array('size'=>15,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'postalCountry'); ?>
	</div>
	<div class="clear"></div>

	<div class="row">
		<?php echo $form->labelEx($model,'physicalAddress'); ?>
		<?php echo $form->textField($model,'physicalAddress',array('size'=>60,'maxlength'=>255)); ?>
		&nbsp;&nbsp;
		<?php echo CHtml::checkBox('',false,array('id'=>'sameAsPostal'));?>
		Same as Postal Address
		<?php echo $form->error($model,'physicalAddress'); ?>
	</div>
	<div class="clear"></div>

	<div class="span-4">
		<?php echo $form->labelEx($model,'physicalSuburb'); ?>
		<?php echo $form->textField($model,'physicalSuburb',array('size'=>15,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'physicalSuburb'); ?>
	</div>

	<div class="span-4">
		<?php echo $form->labelEx($model,'physicalPostcode'); ?>
		<?php echo $form->textField($model,'physicalPostcode',array('size'=>10,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'physicalPostcode'); ?>
	</div>

	<div class="span-4">
		<?php echo $form->labelEx($model,'physicalState'); ?>
		<?php echo $form->dropDownList($model,'physicalState',DataUtil::getStates(),array('empty'=>'')); ?>
		<?php echo $form->error($model,'physicalState'); ?>
	</div>

	<div class="span-4">
		<?php echo $form->labelEx($model,'physicalCountry'); ?>
		<?php echo $form->textField($model,'physicalCountry',array('size'=>15,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'physicalCountry'); ?>
	</div>
	<div class="clear"></div>
</fieldset>

<fieldset>
<legend>Bank Information</legend> 
	<div class="span-8">
		<?php echo $form->labelEx($model,'BankName'); ?>
		<?php echo $form->textField($model,'BankName',array('size'=>40,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'BankName'); ?>
	</div>

	<div class="span-8">
		<?php echo $form->labelEx($model,'BankAccountNumber'); ?>
		<?php echo $form->textField($model,'BankAccountNumber',array('size'=>40,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'BankAccountNumber'); ?>
	</div>
	<div class="clear"></div>
</fieldset>
<fieldset>
<legend>Other</legend>
	<div class="row">
		<?php echo $form->labelEx($model,'note'); ?>
		<?php echo $form->textArea($model,'note',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'note'); ?>
	</div>
</fieldset>
	<div class="buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->